<template>
  <div>
    <go-back></go-back>
      <van-address-list
        v-model="chosenAddressId"
        :list="list"
        default-tag-text="默认"
        @add="onAdd"
        @edit="onEdit"
        />
  </div>
</template>

<script>
import {reqaddressList} from "../../http/http"
export default {
  data() {
    return {
      chosenAddressId: '',
      list: [
        {
          id: '1',
          name: '张三',
          tel: '13000000000',
          address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
          isDefault: true,
        },
      ],
    };
  },
  mounted(){
      //请求数据回来，不是组件要的字段，需要再转换一下
    reqaddressList({
      uid:JSON.parse(localStorage.getItem("user")).uid
    }).then(res=>{
    //   this.list=res.data.list.map(item=>{
    //     return {
    //       id:item.id,
    //       name:item.username,
    //       tel:item.userphone,
    //       address:item.location+item.useraddress,
    //       isDefault:item.status==1
    //     }
    //   })
    })
  },
  methods: {
    onAdd() {
      this.$router.push("/addressAdd")
    },
    onEdit(item, index) {
      this.$router.push("/addressAdd?id="+item.id)
    },
  },
};
</script>

<style>

</style>